package ar.edu.itba.it.cg.grupo01.game.action.score;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Score implements Serializable, Comparable<Score>, Cloneable {

	private static final long serialVersionUID = 1L;
	private long date;
	private long score;
	
	public Score(long score, Date date) {
		super();
		this.date = date.getTime();
		this.score = score;
	}
	
	public Date getDate() {
		return new Date(date);
	}

	public long getScore() {
		return score;
	}
	
	public int compareTo(Score score) {
		return (int) (this.score - score.getScore());
	}
	
	@Override
	public Object clone() throws CloneNotSupportedException {
		Score score =  (Score) super.clone();
		
		score.score = this.score;
		score.date = this.date;
		
		return score;
	}

    @Override
    public String toString() {

        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        return formatter.format(getDate()) + "  " + getScore() + "pts";
    }
}
